#!/usr/bin/env python
# -*- encoding: utf-8 -*-
"""
@File    :   example1.py    
@Contact :   291622538@qq.com

@Modify Time      @Author    @Version    @Description
------------      -------    --------    -----------
2021/4/13 20:00   fan        1.0         None
"""
from neo4j import GraphDatabase, basic_auth

driver = GraphDatabase.driver(
    "neo4j://192.168.37.22:7687",
    auth=basic_auth("neo4j", "nlp302"))

cypher_query = '''
MATCH (m:Movie {title:$movieTitle})<-[:ACTED_IN]-(a:Person) RETURN a.name as actorName
'''

with driver.session(database="neo4j") as session:
    results = session.read_transaction(
        lambda tx: tx.run(cypher_query,
                          movieTitle="The Matrix").data())

    for record in results:
        print(record['actorName'])

driver.close()
